﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TheCell;

namespace SudoForm
{
    internal class FormUtils
    {
        public static void Initialzation(Control container, Type type, List<Cell> cells)
        {
            foreach (Cell cell in cells)
            {
                int line = cell.Location.X;
                int col = cell.Location.Y;
                Control control = type == typeof(mainForm) ? new TextBox() : new Label();//最好用枚举 ?待重写
                control.Location = new System.Drawing.Point(8 + 30 * line, 8 + 30 * col);
                control.Size = new System.Drawing.Size(30, 30);
                control.Name = line.ToString() + "-" + col.ToString();
                control.Tag = cell;
                if (type != typeof(mainForm))
                {
                    control.Text = cell.Value.ToString();
                }
                //((mainForm)container).panel1
                container.Controls.Add(control);
            }
        }

        //public static void Initialzation(Control container, Type type)
        //{
        //    for (int line = 1; line < 10; line++)
        //    {
        //        for (int col = 1; col < 10; col++)
        //        {
        //            Control control = type == typeof(TextBox) ? new TextBox() : new Label();
        //            control.Location = new System.Drawing.Point(8 + 30 * line, 8 + 30 * col);
        //            control.Size = new System.Drawing.Size(30, 30);
        //            control.Name = line.ToString() + "-" + col.ToString();
        //            container.Controls.Add(control);//修改了panel1的访问范围
        //        }
        //    }
        //}
    }
}
